from xgolib import XGO
import time

class DogController:
    def __init__(self):
        self.dog = XGO("xgolite")
    # 从圆柱体中抓取
    def catch_from_cylinder(self):
        self.dog.claw(0)
        time.sleep(1)
        self.dog.motor(11,-30)
        self.dog.motor(21,-30)
        time.sleep(0.5)
        # 张开
        self.dog.arm(100,-30)
        time.sleep(1)
        self.dog.claw(255)
        time.sleep(1)
        self.dog.reset()
        time.sleep(2)
    # 放到圆柱体上
    def put_on_cylinder(self):
        self.dog.motor(11,-30)
        self.dog.motor(21,-30)
        time.sleep(0.5)
        self.dog.arm(100,-30)
        time.sleep(1)
        self.dog.claw(0)
        time.sleep(1)
        self.dog.reset()
        time.sleep(2)
    # 从地上夹取长方条
    def catch_from_ground(self):
        self.dog.claw(0)
        time.sleep(1)
        self.dog.motor(11,-30)
        self.dog.motor(21,-30)
        time.sleep(0.5)
        # 张开
        self.dog.arm(100,-50)
        time.sleep(1)
        self.dog.claw(255)
        time.sleep(1)
        self.dog.reset()  
        time.sleep(2)

if __name__ == "__main__":
    Dog = DogController()
    # Dog.catch_from_ground()
    Dog.catch_from_cylinder()
    # Dog.put_on_cylinder()